package com.distribute.application.api.rest.member;

import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import java.util.Map;

import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import com.distribute.application.api.BaseApiController;
import com.distribute.framework.core.lang.Protocol;
import com.distribute.framework.core.lang.title;
import com.distribute.framework.model.Configur;
import com.distribute.framework.model.Coupon;
import com.distribute.framework.model.DirectCoupon;
import com.distribute.framework.model.Member;
import com.distribute.framework.model.Merchant;
import com.distribute.framework.model.OrderDetails;
import com.distribute.framework.model.Parameter;
import com.distribute.framework.model.TbActivityText;
import com.distribute.framework.model.TbBrandStory;
import com.distribute.framework.model.TbCarouselConfig;
import com.distribute.framework.model.TbOfficialWechat;
import com.distribute.framework.model.TbOfflineZs;
import com.distribute.framework.model.TbPosterImages;
import com.distribute.framework.model.TbShareConfig;

@RestController(value="api.MemberTabOneController")
public class MemberTabOneController  extends BaseApiController{
	@RequestMapping("/api/Merchant/getActivityDetail.do")
	public @title("获取活动详情") Protocol getActivityDetail(
			@title("活动ID") Long id
			){
		Protocol protocol = Protocol.create(true, null);
		protocol.set("obj", TbActivityText.where.tbatId(id).get());
		return protocol;
	}
	@RequestMapping("/api/Merchant/getPosterImgs.do")
	public @title("获取品牌海报图") Protocol getPosterImgs(
			@title("品牌ID") Long banrd
			){
		Protocol protocol = Protocol.create(true, null);
		protocol.setList(TbPosterImages.where.tbpiBrand(banrd).list(-1), new Protocol.BeanFormat<TbPosterImages>(){
			@Override
			public Map format(TbPosterImages t) {
				Map json = t.toJSON();
				return json;
			}
		});
		return protocol;
	}
	@RequestMapping("/api/Merchant/getShars.do")
	public @title("获取分享内容") Protocol getShars(
			@title("页面类型") Short type
			,@title("品牌ID") Long banrd
			){
		Protocol protocol = Protocol.create(true, null);
		TbShareConfig shareConfig=TbShareConfig.where.tbscBrand(banrd).tbscType(type).get();
		protocol.set("obj", shareConfig.toJSON(true));
		return protocol;
	}
	@RequestMapping("/api/Merchant/getGFGZqrcode.do")
	public @title("获取官方二维码") Protocol getGFGZqrcode(
			@title("品牌ID") Long banrd
			){
		Protocol protocol = Protocol.create(true, null);
		TbOfficialWechat shareConfig=TbOfficialWechat.where.tbowBrand(banrd).get();
		protocol.set("obj", shareConfig.toJSON(true));
		return protocol;
	}
	@RequestMapping("/api/Merchant/getBanrdGS.do")
	public @title("获取品牌故事") Protocol getBanrdGS(
			@title("品牌ID") Long banrd
			){
		Protocol protocol = Protocol.create(true, null);
		TbBrandStory shareConfig=TbBrandStory.where.tbbsBrand(banrd).get();
		protocol.set("obj", shareConfig.toJSON(true));
		return protocol;
	}
	@RequestMapping("/api/Merchant/getBanrdZhaoShang.do")
	public @title("获取线下招商内容") Protocol getBanrdZhaoShang(
			@title("品牌ID") Long banrd
			){
		Protocol protocol = Protocol.create(true, null);
		TbOfflineZs shareConfig=TbOfflineZs.where.tbozBrand(banrd).get();
		protocol.set("obj", shareConfig.toJSON(true));
		return protocol;
	}
	@RequestMapping("/api/Merchant/getHomeScorllImgs.do")
	public @title("获取首页顶部轮播图数据") Protocol getHomeScorllImgs(
			
			){
		Protocol protocol = Protocol.create(true, null);
		Configur  configur = Configur.where.status((short)1).get();
		protocol.set("obj", configur);
		return protocol;
	}
	
	
	/**
	 * 进入品牌首页
	 * @param id
	 * @return
	 */
	@RequestMapping("/api/tabOne/gotoBrandHome.do")
	public @title("进入品牌首页")  Protocol gotoBrandHome(
			@title("品牌ID") Long id
	){
		Protocol protocol = Protocol.create(true, null);
		Parameter parameter=Parameter.where.merchant(id).get();
		Merchant merchant=Merchant.where.id(id).get();
		protocol.set("merchant", merchant.toJSON());
		protocol.set("pam", parameter);
		return protocol;
	}
	/**
	 * 获取关注信息
	 * @return
	 */
	@RequestMapping("/api/tabOne/getFollowInfo.do")
	public @title("获取关注信息")  Protocol getFollowInfo(
			@title("品牌ID") Long id
	){
		Protocol protocol = Protocol.create(true, null);
		Merchant merchant=Merchant.where.id(id).get();
		protocol.set("merchant", merchant.toJSON());
		return protocol;
	}
}
